package org.batatasframework.support.searchable.result;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import org.batatasframework.support.database.spi.ResultWritable;



public class SearchResultRow implements ResultRow {
	
	protected final List<ResultCell> cells = new ArrayList<>();
	
	public SearchResultRow(List<? extends ResultHead> heads){
		for(ResultHead head : heads){
			cells.add(head.newCell());
		}
	}

	@Override
	public void read(ResultSet rs) throws Exception {
		for(ResultCell cell : cells){
			cell.read(rs);
		}
	}

	@Override
	public void writeTo(ResultWritable resultWriter) throws Exception {
		resultWriter.newLine();
		for(ResultCell cell : cells){
			cell.writeTo(resultWriter);
		}
	}
}
